package com.demo.inst;

import java.util.HashMap;
import java.util.Map;

public class CacheUtis {
	
	
	private static Map<String, Object> cacheMap = new HashMap<>();
	private static Map<String, Object> cacheMap2 = null;
	
	public static Map<String, Object> getInstanceMap(){
		return cacheMap;
	}
	
	public static Map<String, Object> getInstanceMap2(){
		if(cacheMap2==null){
			cacheMap2 = Singleton.cacheMap;
		}
		return cacheMap2;
	}
	
	
	
	/**
	 * 通过内部类 从jvm 低层实现了单例模式
	 * 注意:不支持序列化和反序列化
	 * */
	private static class Singleton{
		private static  Map<String, Object> cacheMap = new HashMap<>();
	}
	
	public static Map<String, Object> getInstance(){
		return Singleton.cacheMap;
	}
	
}
